package com.itheima.sc.web.pms;

import com.itheima.sc.autoconfig.template.OssTemplate;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.pms.AliyunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("aliyun")
public class AliyunController {

    @Autowired
    private AliyunService aliyunService;

    @PostMapping("/oss/upload")
    public Result upload(MultipartFile photoFile){
        String url = aliyunService.upload(photoFile);
        Map<String,String> map = new HashMap<>();
        map.put("url",url);
        return Result.success(map);
    }

}
